﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=11">
        <link rel="stylesheet" href="<%=basePath %>css/cssreset.css">
        <link rel="stylesheet" href="<%=basePath %>css/pagination.css">
        <link rel="stylesheet" href="<%=basePath %>css/bumenyonghuguanli.css">
        <link rel="stylesheet" href="<%=basePath %>css/daohang.css">
        <script src="<%=basePath %>js/jquery-1.11.1.min.js"></script>
        <script src="<%=basePath %>js/jquery.pagination.js"></script>
        <script src="<%=basePath %>js/menu1.js"></script>
        <script src="../js/jquery.table2excel.js"></script>
    </head>
    <style>
		.zcd>a{
			color:#7896b7;
			text-decoration: none;
			cursor:pointer;
		}
		.psxa{
			color:#708dac;
			width:100%;
			line-height:23px;
			text-align: center;
			margin-top:27px;
			font-family: '微软雅黑';
			cursor:pointer;
			font-size:16px;
		}
		.psxa>a{
			text-decoration:none;
			color:#708dac;
		}
		a{
			text-decoration:none;
			color:#708dac;
		}
		.ims{
			position:relative;
			top:4px;
			right:22px;
		}
		#updateStaff td>input{
			width:12px;
			height:12px;
		}
	</style>
    <body>
    	<div class="headers">
    		<p class="pa">客户管理系统CRM</p>
    		<p class="rights">
	    		<img src="<%=basePath %>images/user.png" alt="">
	    		${staff.staff_name}
	    		<button onclick="ind()"></button>
    		</p>
    	</div>
    	<section>
    		<jsp:include page="/client/html/htop.jsp"></jsp:include>
    		<div class="righta">
    			<div class="lefta">
    				<form action="<%=basePath %>staff/saveCompany.action" method="post" class="formas" onsubmit="return gonsi()">
                        <input type="text" name="company_name" placeholder="&nbsp;公司名称" id="gongsi">
                        <input type="submit" value="添加" class="cla">
                    </form> 
                    <c:forEach items="${map}" var="map">
		    			<div class="zhankai" onclick="selectComId(${map.key.company_id})">
	                        <img class="imga" src="../images/zhankai.png" alt="">
	                        ${map.key.company_name}
	                        <img src="../images/jiahao.png" alt="" class="imgb" onclick="saveDepartmentPage(${map.key.company_id})">
	                        <img src="../images/edit.png" alt="" class="imgbb" >
	                        <img src="../images/delete.png" alt="" class="imgc">
	                        <div class="div2">
	                       	<c:forEach items="${map.value}" var="val">
	                            	<div class="zcd1" id="zcd1" onclick="dia(${val.key.department_id})" >
	                                <img class="imga" src="../images/zhankai.png" alt="">
	                                ${val.key.department_name}
	                                <img src="../images/jiahao.png" alt="" class="imgbc">
	                                <img src="../images/edit.png" alt="" class="imgba" onclick="updateDepartmentPage(${val.key.department_id})">
	                                <img src="../images/delete.png" alt="" class="imgca" onclick="deleteDepar(${val.key.department_id})">
	                                <c:forEach items="${val.value}" var="top">
	                                	<div class="pals">
	                                 		${top.department_name}
		                                    <img src="../images/edit.png" alt="" class="imgas" onclick="updateDepartmentPage(${top.department_id})">
		                                    <img src="../images/delete.png" alt="" class="imgbs" onclick="deleteDepar(${top.department_id})">
		                                </div>
	                                </c:forEach>
	                            </div>
	                         </c:forEach>
	                        </div>
	                    </div>
                    </c:forEach>
    			</div>
    			</div>
    			
    			<div class="rightb">
    				<p class="pas">部门用户管理</p>
    				<div class="diva" style="overflow:hidden;">
    				   <form action="<%=basePath %>staff/selectTree.action" method="post">
	    				<input type="text" placeholder="按姓名、邮箱、手机号查找" id="searchBox" name="condition" value="${condition}">
	    				<input type="submit" value="搜索"  class="butss" >
	    				</form>
	    				<span id="checkedShow" style="display:none;">
	    					<span class="yixianze">已选择<span id="number"></span>项</span>
	    					<span class="spanb" id = "deleteStaff" onclick="deleteStaff()" style="cursor:pointer">删除</span>
	    					<span class="spanc" onclick="updateStaffPage()" style="cursor:pointer">编辑</span>
	    					<span class="spand" onclick="updateRolePage()" style="cursor:pointer">分配角色</span>
	    				</span>
	    					<button class="imgx"></button>
	    					<button class="imgd" onclick="saveStaffPage()"></button>
	    					<div class="dia">
	                                <p class="daoru">导入员工</p>
	                                <p class="daochu">导出员工</p>
	                           </div>
    				</div>
    			</div>
    			<table id="updateStaff" style="position:relative;left:10px;">
    				<thead>
    					<tr class="tras">
    						<td><input type="checkbox" id="selectCheck" value="1" onclick="selectCheck()" /></td>
    						<td>姓名</td>
    						<td>手机号</td>
    						<td>邮箱</td>
    						<td>性别</td>
    						<td>职位</td>
    						<td>部门</td>
    						<td>入职日期</td>
    					</tr>
    					<%-- <c:forEach items="${listStaff}" var="staff">
    						<tr class="listStaffTr">
    						<td><input type="checkbox" name="items" value="${staff.staff_id}" onclick="checkedShow()" /></td>
    						<td class="names" onclick="names(${staff.staff_id})" style="cursor:pointer">${staff.staff_name}</td>
    						<td>${staff.staff_phone}</td>
    						<td>${staff.staff_email}</td>
    						<td>${staff.staff_sex}</td>
    						<td>${staff.staff_job}</td>
    						<td>
    							<c:forEach items="${departments}" var="department" >
   									<c:if test="${staff.staff_departmentId==department.department_id}">
   										${department.department_name}
   									</c:if>
    							</c:forEach>
    						</td>
    						<td>
    							<fmt:formatDate value="${staff.staff_entryDate}" type="date"/>
    						</td>
    						
    					</tr>
    					</c:forEach> --%>
    				</thead>
    				<tbody>
    					
    				
    				</tbody>
    			</table>
    			<div class="M-box" style="width:50%;margin: 30px auto;padding-left: 350px;margin-bottom: 15px;"></div>
    		</div>
    	</section>
    	<div class="smalls"></div>
    	<div class="bianji">
    		<p class="paa">&nbsp;&nbsp;&nbsp;&nbsp;编辑角色<span class="guan" style="cursor:pointer"><img src="<%=basePath %>images/guanbi.png" alt=""></span></p>
    		<form action="javascript:updateStaff()" method="post" onsubmit="return aa()">
    			<ul class="bianjiul">
    				<li class="bianjili"><span class="lispan">账号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" name="username" id="user"><span>*</span></li>
    				<li><span class="lispan">密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" name="password" id="pass"><span>*</span></li>
    				<li><span class="lispan">姓名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="namee"><span>*</span></li>
    				<li><span class="lispan">性别&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="lisex" type="radio" value="男" name="sex" style="margin-left:53px;float:none;width:15px;height:15px;">男<input style="margin-left:53px;float:none;width:15px;height:15px;" class="lisex" type="radio" value="女" name="sex">女</li>
    				<li><span  class="lispan">手机号&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="phones"></li>
    				<li><span class="lispan">邮箱号&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="emails"></li>
    				<li><span class="lispan">职位&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="jobs" value=""> <span>*</span></li>
    				<li>
    					<span class="lispan">部门&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    					<select  id="selectDep">
    						
                    	</select>
                    	<span>*</span>
                    </li>
    				<li>
    					<span class="lispan">直属上级&nbsp;</span>
    					<select name="" id="topStaffId">
	    					<option value="">
	    					</option>
                    	</select>
                    	<span>*</span>
                    </li>
    				<li><span class="lispan">入职日期&nbsp;</span><input class="liinput" type="text" id="datess" onfocus="WdatePicker({skin:'whyGreen',dateFmt: 'yyyy-MM-dd', readOnly:true})"></li>
    				<input type="hidden" name="staff_id" id="staff_ids">
    			</ul>
    			 
    			<div class="smills"><input type="submit" value="确定" style="cursor:pointer"></div>
    		</form>
    	</div>
    	<div class="divaa">
    		<p class="paa">&nbsp;&nbsp;&nbsp;&nbsp;分配角色
    			<span class="guan">
    				<img src="<%=basePath %>images/guanbi.png" alt="" style="cursor:pointer;">
    			</span>
    		</p>
			<form action="javascript:updateRole()" method="post">
				<span id = "roleList">
				</span>
				<p class="paf"><input type="submit" value="确定" style="cursor:pointer"></p>
			</form>
    	</div>
    	<div class="xinjian">
    		<p class="paa">&nbsp;&nbsp;&nbsp;&nbsp;新建员工<span class="guan" style="cursor:pointer"><img src="<%=basePath %>images/guanbi.png" alt=""></span></p>
    		<form action="javascript:saveStaff()" method="post" onsubmit="return bb()">
    			<ul>
    				<li class="xinjianli"><span class="lispan">姓名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="staffName"><span>*</span></li>
    				<li><span class="lispan">手机号&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="staffPhone"></li>
    				<li><span class="lispan">密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" name="password" id="staffPassWord"><span>*</span></li>
    				<li><span class="lispan">性别&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input style="margin-left:53px;" type="radio" value="男" name="staffSex" class="sexs">男<input style="margin-left:53px;float:none;width:15px;height:15px;"  class="sexs" type="radio" value="女" name="staffSex">女</li>
    				<li><span class="lispan">邮箱号&nbsp;&nbsp;&nbsp;</span><input class="liinput" type="text" id="staffEmail"></li>
    				<li>
    					<span class="lispan">职位&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    					<input class="liinput" type="text" value="" id="staffJob">
                    	<span>*</span></li>
    				<li>
    					<span class="lispan">部门&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
    					<select name="" id="sels" onchange="selectTopStaffId()">
                        	
                    	</select>
                    	<span>*</span></li>
    				<li>
    					<span class="lispan">直属上级&nbsp;</span>
    					<select name="" id="sel">
                        	
                    	</select>
                    	<span>*</span>
    				</li>
    				<li><span class="lispan">入职日期&nbsp;</span><input class="liinput" type="date" id="staffDate" class="shurukuang Wdate" style="height: 30px;1px solid #bfbfbf;"   onfocus="WdatePicker({skin:'whyGreen',dateFmt: 'yyyy-MM-dd', readOnly:true})"></li>
    			</ul>
    			<div class="smills"><input type="submit" value="确定"></div>
    		</form>
    	</div>
        <div class="bumens">
            <p>新建部门<img src="<%=basePath %>images/guanbi.png" alt="" style="cursor:pointer"></p>
            <form action="javascript:saveDepartment()" method="post">
                <p>
                	<span>部门名称&nbsp;&nbsp;:</span><input type="text" id="depar_name"><br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<span>上级部门&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;</span>
                	<select name="department_departmentId"  id="departmentSelect">
                		<option value="">请选择上级部门</option>
                	</select> 	
                </p>
                
                <p><input type="submit" value="确定"></p>
            </form>
        </div>
        <div class="bumensa">
            <p>编辑部门<img src="<%=basePath %>images/guanbi.png" alt=""></p>
            <form action="javascript:updateDepartment()" method="get">
                <p>
                	<span>部门名称&nbsp;&nbsp;:</span><input type="text" id="bumenssss"><br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                	<span>上级部门&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;</span>
                	<select name="department_departmentId1" id="department_departmentId">
                	
                	</select>
                
                </p>
                <p><input type="submit" value="确定"></p>
            </form>
        </div>
       <div class="dao">
            <p>导入数据<img src="../images/guanbi.png" alt=""></p>
            <div>
                <p>仅支持以逗号为分隔符的文本文件【filename.csv】,文件最大10MB。请按照数据模板的格式导入数据,模板中的表头名称不可更改,表头行不能删除。</p>
                <p><a href="../staff/downFile.action">下载数据模板</a></p>
                <form id="upload-form" action="javascript:excilClient()" method="post" onsubmit="return fileSelect()" enctype="multipart/form-data" >
                　　<div>
                        <p>请选择需要导入的csv文件</p>
                        <p><input type="file" name="file" id="filea"/></p>
                    </div>
                    <p>上传文件可能需要几分钟，取决于文件大小和网速</p>
                　　<p><input type="button" value='取消' class="buts"><input type="button" onclick="UpladFile()" value="导入" /></p>
                </form>
            </div>
        </div>
        <div class="bumensaa">
            <p>新建分组<img src="../images/guanbi.png" alt=""></p>
            <form action="javascript:saveDepDow()" method="post" onclick="">
                <p><span>小组名称&nbsp;&nbsp;:</span><input type="text" id="fenzus"></p>
                <p><input type="submit" value="确定"></p>
            </form>
        </div>
        <div class="ba">
            <p>编辑公司<img src="../images/guanbi.png" alt="" onclick="guanbin()"></p>
            <form action="" method="post" onclick="">
                <p><span>公司名称&nbsp;&nbsp;:</span><input type="text" id="bumen"></p>
                <p><input type="submit" value="确定"></p>
            </form>
        </div>
        <div class="fenzu">
        	<p>编辑分组<img src="../images/guanbi.png" alt="" class="fenzus"></p>
        	<form action="" method="post">
        		<p>分组名称&nbsp;:<input type="text"/></p>
        		<p>所属部门&nbsp;:
        			<select >
        				<option></option>
        			</select>
        		</p>
        		<p><input type="submit" value='确定'/></p>
        	</form>
        </div>
        <div style="display: none">
        	<p class="companyId"></p>
       	 	<p class="department_id"></p>
        	<p class="staff_id">
        </div>
        <script src="<%=basePath %>salejihui/My97DatePicker/WdatePicker.js"></script>
    </body>
    <script>
    $(function(){
    	$('.M-box').pagination({
        	pageCount: ${PageCount},//总页数
    		current: ${PageNum},//当前页码
    		callback:function(api){
    			var pageNum=api.getCurrent();
    			  var condition="${condition}";
    	        $.ajax({  
    	            type : "POST",  
    	            url : "<%=basePath%>staff/selectAll.action",//路径  
    	            data : {  
    	            	pageNum : api.getCurrent(),	     
    	            	"condition" : condition
    	            },
    	            success : function(data) {
    	            	pageNums=api.getCurrent();
    	            	var number=data[0].number;//总页数
    	            	api.setPageCount(number);//动态修改总页数为20页
    	            	var pageNum=data[0].pageNum;
    	            	var text="";
    	            	$('.listStaffTr').remove();
                      for(var i=0;i<data[0].list.length;i++){
                    	  
                           text=$('<tr class="listStaffTr">'
                         		   +'<td><input type="checkbox" name="items" value="'+data[0].list[i].staff_id+'" onclick="checkedShow()" /></td>'
                        		   +'<td class="names" onclick="names('+data[0].list[i].staff_id+')" style="cursor:pointer">'+data[0].list[i].staff_name+'</td>'
                        		   +'<td>'+data[0].list[i].staff_phone+'</td>'
                        		   +'<td>'+data[0].list[i].staff_email+'</td>'
                        		   +'<td>'+data[0].list[i].staff_sex+'</td>'
                        		   +'<td>'+data[0].list[i].staff_job+'</td>'
                        		   +'<td>'+data[0].list[i].department_name+'</td><td>'+data[0].list[i].staff_entryDate+'</td></tr>')
                           $('tbody').append(text);
                          }
    	    			/*<div class="content trs"><h6 class="sbox1"><span>审批人：'+data[0].list[i].ApproverId+'</span><span>类别：'+data[0].list[i].type+'</span><span>审批状态：'+data[0].list[i].approvalState+'</span><span>提交日期：'+data[0].list[i].saleStageName+'</span></h6><h5 class="ssbox1">正文：'+data[0].list[i].contractContent+'</h5><a href="#" class="more" onclick="dian('+data[0].list[i].approveId+','+pageNum+')">查看更多 ></a></div>*/
    	            }
    	        });  
    	    }
    	},function(api){
    	    var pageNum;
    	    var condition="${condition}";
    	    $.ajax({  
    	        type : "POST",  
    	        url : "<%=basePath%>staff/selectAll.action",//路径  
    	        data : {  
    	        	pageNum : api.getCurrent(),
    	        	"condition" : condition
    	        },
    	        success : function(data) {		     
    	        	var number=data[0].number;//总页数
    	        	api.setPageCount(number);//动态修改总页数为20页
    	        	var pageNum=data[0].pageNum;
    	        	var text=""; 
    	        	console.log(data);
                    for(var i=0;i<data[0].list.length;i++){
                    	
                            text=$('<tr class="listStaffTr">'
                 		   +'<td><input type="checkbox" name="items" value="'+data[0].list[i].staff_id+'" onclick="checkedShow()" /></td>'
                		   +'<td class="names" onclick="names('+data[0].list[i].staff_id+')" style="cursor:pointer">'+data[0].list[i].staff_name+'</td>'
                		   +'<td>'+data[0].list[i].staff_phone+'</td>'
                		   +'<td>'+data[0].list[i].staff_email+'</td>'
                		   +'<td>'+data[0].list[i].staff_sex+'</td>'
                		   +'<td>'+data[0].list[i].staff_job+'</td>'
                		   +'<td>'+data[0].list[i].department_name+'</td><td>'+data[0].list[i].staff_entryDate+'</td></tr>')
                           $('tbody').append(text);
                          }                               	
    	        }
    	    });  
    	});
    });
    
    
    
    
    $('.bumensaa>p>img').click(function(event) {
        $('.smalls').css('display', 'none');
       $('.bumensaa').css('display', 'none'); 
   });
    $(".pals").click(function(){
    	
        if($(this).children(".imgas").css("display")=="none"){
        	
        	 $(".imgas").css("display","inline");
        	 $(this).siblings().children('.imgas').css("display","none");
        }else{
        	$(this).children('.imgas').hide();
        }
        if($(this).children(".imgbs").css("display")=="none"){

        	 $(".imgbs").css("display","inline");
        	 $(this).siblings().children('.imgbs').css("display","none");
        }else{
        	$(this).children('.imgbs').hide();
        }
        
    });
    $('.imgas').click(function(){
    	$('.fenzu').css('display', 'block');
		$('.smalls').css('display', 'block');
    })
    $('.fenzus').click(function(){
    	$('.fenzu').css('display', 'none');
		$('.smalls').css('display', 'none');
    })
    $(".imgx").click(function(){

		if($(".dia").css("display")=="none"){

		$(".dia").show();

		}else{

		$(".dia").hide();

		}

		});
    function show(){
		window.location.href="<%=basePath %>approve/Findnoapprove.action";
  }
  $(function() {
            $(".daochu").click(function(){
                $("table").table2excel({
                    //exclude: ".noExl",
                    name: "Excel Document Name",
                    filename: "myFileName",
                    exclude_img: true,
                    exclude_links: true,
                    exclude_inputs: true
                });
            });
            
        });
    	$('.spanc').click(function(event) {
    		var number = 0;
    		var obj = document.getElementsByName("items");
			for(var i = 0,l = obj.length;i < l;i++){
				if(obj[i].checked){
					number++;
				}
			} 
			if(number > 1){
				alert("只能编辑一项");
				$('.smalls').css('display', 'none');
				return;
				
			}
			if(number == 0){
				alert("请选择要编辑的数据");
				$('.smalls').css('display', 'none');
				return;
			}
			if(number == 1){
				$('.bianji').css('display', 'block');
	    		$('.smalls').css('display', 'block');
				return;
				
			}
    		
    		
    	});
    	var gosi=document.getElementById('gongsi');
        function gonsi(){
            var gos=gosi.value;
            var pat=/\s/;
            var val=true;
            if(gos==''||pat.test(gos)){
                alert('请输入公司名称！');
                val=val&&false;
            }
            return val;
        }
    	/* $('.spanc').click(function(event) {
    		$('.bumen').css('display', 'block');
    		$('.smalls').css('display', 'block');
    	}); */
    	$('.zcd1').click(function(event) {
            $('.imgba').css('display', 'inline');
            $('.imgca').css('display', 'inline');
            $('.imgbc').css('display', 'inline');
            $(this).children('.imga').attr('src', '../images/xiala.png');
            $(this).siblings('').children('.imgba').css('display', 'none');
            $(this).siblings('').children('.imgca').css('display', 'none');
            $(this).siblings('').children('.imgbc').css('display', 'none');
            $(this).siblings('').children('.imga').attr('src', '../images/zhankai.png');
        });
        $('.imgbc').click(function(event) {
            $('.smalls').css('display', 'block');
            $('.bumensaa').css('display', 'block'); 
        });
        $('.daoru').click(function(event) {
            $('.dao').css('display', 'block');
            $('.smalls').css('display', 'block');
        });
        $('.dao>p>img').click(function(event) {
            $('.dao').css('display', 'none');
            $('.smalls').css('display', 'none');
        });
        $('.buts').click(function(event) {
            $('.dao').css('display', 'none');
            $('.smalls').css('display', 'none');
        });



    	$('.dia>p').click(function(event) {
            $('.dia').fadeOut();
        });
    	$('.guan').click(function(event) {
    		$('.bianji').css('display', 'none');
    		$('.smalls').css('display', 'none');
    		$('.divaa').css('display', 'none');
    		$('.bumen').css('display', 'none');
    		$('.xinjian').css('display', 'none');
    	});
    	$('.spand').click(function(event) {
    		$('.divaa').css('display', 'block');
    		$('.smalls').css('display', 'block');
    	});
    	$('.imgd').click(function(event) {
    		$('.xinjian').css('display', 'block');
    		$('.smalls').css('display', 'block');
    	});
        $('.zhankai>img:nth-of-type(2)').click(function(event) {
            $('.smalls').css('display', 'block');
            $('.bumens').css('display', 'block');           
        });
        $('.zhankai>img:nth-of-type(3)').click(function(event) {
        	 $('.ba').css('display', 'block'); 
	          $('.smalls').css('display', 'block');           
        });
        $('.bumens>p>img').click(function(event) {
             $('.smalls').css('display', 'none');
            $('.bumens').css('display', 'none'); 
        });
        $('.imgba').click(function(event) {
             $('.smalls').css('display', 'block');
            $('.bumensa').css('display', 'block');
        });
        $('.bumensa>p>img').click(function(event) {
             $('.smalls').css('display', 'none');
            $('.bumensa').css('display', 'none'); 
        });
        var users=document.getElementById('user');
        var passs=document.getElementById('pass');
        var namee=document.getElementById('namee');
        var sel=document.getElementById('sel');
        var sels=document.getElementById('sels');
        function aa(){
            var val=true;
            var pas=passs.value;
            var nam=namee.value;
            var se=sel.value;
            var ses=sels.value;
           if(pas==''){
                alert('请输入密码!');
                val=val&&false;
            }else if(nam==''){
                alert('请输入姓名!');
                val=val&&false;
            }else if(se==' '||se==null){
                alert('请选择职位!');
                val=val&&false;
            }else if(ses==' '||ses==null){
                alert('请选择部门!');
                val=val&&false;
            }
            return val;
        }
        
        users.onblur=function(){
            var use=user.value;
            if(use==''){
                alert('请输入账号!');
            }
        }
        
        passs.onblur=function(){
            var pas=pass.value;
            if(pas==''){
                alert('请输入密码!');
            }
        }
        namee.onblur=function(){
            var na=namee.value;
            if(na==''){
                alert('请输入姓名!');
            }
        }


        var us=document.getElementById('use');
        var pa=document.getElementById('pas');
        var nams=document.getElementById('names');
        function bb(){
            var uss=us.value;
            var paa=pa.value;
            var na=nams.value;
            var val=true;
            if(uss==''){
                alert('请输入账号!');
                val=val&&false;
            }else if(paa==''){
                alert('请输入密码!');
                val=val&&false;
            }else if(na==''){
                alert('请输入姓名!');
                val=val&&false;
            }
            return val;
        }

        us.onblur=function(){
            var use=us.value;
            if(use==''){
                alert('请输入账号!');
            }
        }
        
        pa.onblur=function(){
            var pas=pa.value;
            if(pas==''){
                alert('请输入密码!');
            }
        }
        nams.onblur=function(){
            var nas=nams.value;
            if(nas==''){
                alert('请输入姓名!');
            }
        }


       function saveDepartmentPage(department_companyId){
    	   $(".companyId").html(department_companyId); 
   		   $(".companyId").hold;
    	   $("#departmentSelect").html("");
    	   var baa = "<option value=''>请选择</option>";
    	   $("#departmentSelect").append(baa);
    	   $.ajax({
   			type:"post",
   			data:"department_companyId="+department_companyId,
   			url:"<%=basePath %>staff/saveDepartmentPage.action",
   			success:function(data){
				 var json = eval("("+data+")");
				 for(var i = 0;i < json.length;i++){
					 var a = "<option value="+json[i].department_id+">"+json[i].department_name+"</option>"
					 $("#departmentSelect").append(a);
				 }
				 
   				
   			},
   			error:function(e){
   				alert("发生未知错误请刷新页面");
   			}
   			
   			});
    		
       }
       
       function saveDepartment(){
    	   var name = $("#depar_name").val();
    	   if(name == ""){
    		   alert("部门名称不能为空");
    		   return;
    	   }
    	   var department_departmentId = $("#departmentSelect").val();
    	   var department_conpanyId = $(".companyId").html();

    	   		$.ajax({
    	   			type:"post",
    	   			data:{department_departmentId:department_departmentId,
    		   			  department_name:name,
    		   			  department_companyId:department_conpanyId
    		   			 },
    	   			url:"<%=basePath %>staff/saveDepartment.action",
    	   			success:function(data){
    						alert(data);
    						if(data == "新增成功"){
    							location.href="<%=basePath %>staff/selectTree.action";
    						}
    	   				
    	   			},
    	   			error:function(e){
    	   				alert("发生未知错误请刷新页面");
    	   			}
    	   			
    	   		});
    	  
       	}
       
       function updateDepartmentPage(department_id){
    	   $("#department_departmentId").html("");
    	   var baa = "<option value=''>请选择</option>";
    	   $("#department_departmentId").append(baa);
    	   $.ajax({
   			type:"post",
   			data:"department_id="+department_id,
   			url:"<%=basePath %>staff/findDepartmentId.action",
   			success:function(data){
   				var jsons = eval("("+data+")");
	   			$.ajax({
	   				type:"post",
	   				data:"department_companyId="+jsons[0].department_companyId,
	   				url:"<%=basePath %>staff/saveDepartmentPage.action",
	   				async: false,
	   				success:function(data1){
	   					var json = eval("("+data1+")");
	   					for(var i = 0;i < json.length;i++){
	   					 	var a = "<option value='"+json[i].department_id+"'>"+json[i].department_name+"</option>"
	   					 	$("#department_departmentId").append(a);
	   					}
	   					$("#department_departmentId option[value='"+jsons[0].department_departmentId+"']").attr("selected",true);
	   				},
	   				error:function(e){
	   					alert("发生未知错误请刷新页面");
	   				}

   	   		  	}); 
   				$("#bumenssss").val(jsons[0].department_name);
   				$(".department_id").html(jsons[0].department_id);
   				$(".department_id").hold;
   			  },
   			  error:function(e){
   				alert("发生未知错误请刷新页面");
   			  }
      	   });   
    	   event.stopPropagation(); 
       }
       
       function updateDepartment(){
    	   var name = $("#bumenssss").val();
    	   if(name == ""){
    		   alert("部门名称不能为空");
    		   return;
    	   }
    	   var department_id = $(".department_id").html();
    	   var topId = $("#department_departmentId").val();
    	   $.ajax({
  				type:"post",
  				data:"department_id="+department_id+"&department_name="+name+"&department_departmentId="+topId,
  				url:"<%=basePath %>staff/updateDepartment.action",
  				success:function(data){
  					alert(data);
  					if(data == "修改成功"){
  						location.href="<%=basePath %>staff/selectTree.action";
  					}
  				},
  				error:function(e){
  					alert("发生未知错误请刷新页面");
  				}

	   		  }); 
    	   event.stopPropagation(); 
       }
       
       function deleteDepar(department_id){
    	   $.ajax({
  				type:"post",
  				data:"department_id="+department_id,
  				url:"<%=basePath %>staff/deleteDepartment.action",
  				success:function(data){
  					alert(data);
  					if(data == "删除成功"){
  						location.href="<%=basePath %>staff/selectTree.action";
  					}
  				},
  				error:function(e){
  					alert("发生未知错误请刷新页面");
  				}

	   		  });
    	   event.stopPropagation(); 
       }
       
       function findByDepartmentaa(department_id){
    	   $(".department_id").html(department_id);
    	   $.ajax({
 				type:"post",
 				data:"id="+department_id,
 				url:"<%=basePath %>staff/findByDepId.action",
 				success:function(data){
 					$.ajax({
 		 				type:"post",
 		 				data:"department_id="+department_id,
 		 				url:"<%=basePath %>staff/findDepartmentId.action",
 		 				success:function(datas){
 		 					var jso = eval("("+datas+")");
 		 					var jsons = eval("("+data+")");
 		 					$(".listStaffTr").remove();
 		 					for(var i =0,l = jsons.length;i < l;i++){
 		 						var year = jsons[i].staff_entryDate.year + 1900;
 		 						var month = jsons[i].staff_entryDate.month + 1;
 		 						var date = jsons[i].staff_entryDate.date;
 		 						var entryDate = year+"-"+month+"-"+date;
 								var staff = "<tr class='listStaffTr'><td><input type='checkbox' name='items' value='"+jsons[i].staff_id+"' onclick='checkedShow()'/></td><td>"+jsons[i].staff_name+"</td><td>"+jsons[i].staff_userName+"</td><td>"+jsons[i].staff_phone+"</td><td>"+jsons[i].staff_email+"</td><td>"+jsons[i].staff_sex+"</td><td>"+jsons[i].staff_job+"</td><td>"+jso[0].department_name+"</td><td>"+entryDate+"</td></tr>";
 		 						$("#updateStaff").append(staff);
 		 					}
 		 				},
 		 				error:function(e){
 		 					alert("发生未知错误请刷新页面");
 		 				}

 			   		 });
 				},
 				error:function(e){
 					alert("发生未知错误请刷新页面");
 				}

	   		 });
       }
       
       function checkedShow(){
    	   var str = "";
    	   var number = 0;
    	   var obj = document.getElementsByName("items");
			for(var i = 0,l = obj.length;i < l;i++){
				if(obj[i].checked){
					str += obj[i].value+",";
					number++;
				}
			}    	   
    			
    	   if(str == ""){
    		   $("#checkedShow").hide();
    	   }else{
    		   $(".staff_id").html(str);
    		   $("#checkedShow").show();
    		   $("#number").html(number);
    	   }
    		   
    	   
       }
       
       function selectCheck(){
    	   var judge = $("#selectCheck").val();
    	   var objs = document.getElementsByName("items");
		   if(judge == 1){
			   for(var i = 0,l = objs.length;i < l;i++){
	    		   objs[i].checked = true;
	    	   }
			   $("#selectCheck").val(0);
    	   }else{
    		   for(var i = 0,l = objs.length;i < l;i++){
	    		   objs[i].checked = false;
	    	   }
    		   $("#selectCheck").val(1);
    	   }
    	   
    	   checkedShow();
       }
       function names(staff_id){
    	   
    	   $.ajax({
				type:"post",
				data:"staff_id="+staff_id,
				url:"<%=basePath %>staff/findById.action",
				success:function(data){
					var staff = eval("("+data+")");
					$("#user").val(staff[0].staff_userName);
					$("#staff_ids").val(staff[0].staff_id);
					$("#pass").val(staff[0].staff_password);
					$("#namee").val(staff[0].staff_name);
					$("#phones").val(staff[0].staff_phone);
					$("#emails").val(staff[0].staff_email);
					$("#jobs").val(staff[0].staff_job);
					var sex = document.getElementsByName("sex");
					for(var se = 0;se<sex.length;se++){
						if(sex[se].value == staff[0].staff_sex){
							sex[se].checked = true;
						}	
					}
					
					var year = staff[0].staff_entryDate.year + 1900;
					var month = staff[0].staff_entryDate.month + 1;
					var date = staff[0].staff_entryDate.date;
					var staff_entryDate = year + "-" + month + "-" + date;
					$("#datess").val(staff_entryDate);
					
					$.ajax({
		 				type:"post",
		 				data:"id="+staff[0].staff_departmentId,
		 				url:"<%=basePath %>staff/findByDepId.action",
		 				success:function(staffId){
		 					var staffid = eval("("+staffId+")");
		 					$("#topStaffId").html("");
		 					var moren = "<option value=''>请选择</option>";
		 					$("#topStaffId").append(moren);
		 					for(var st = 0;st<staffid.length;st++){
		 						var staf = staffid[st];
		 						var depass = "<option value='"+staf.staff_id+"'>"+staf.staff_name+"</option>";
	 		 					$("#topStaffId").append(depass);
		 					}
		 					$("#topStaffId option[value='"+staff[0].staff_superior+"']").attr("selected",true);
		 					
		 					$("#selectDep").html("");
		 		    	    var baa = "<option value=''>请选择</option>";
		 		    	    $("#selectDep").append(baa);
		 					$.ajax({
		 		 				type:"post",
		 		 				url:"<%=basePath %>staff/findAllDeps.action",
		 		 				success:function(staff_depar){
		 		 					var dep = eval("("+staff_depar+")");
		 		 					for(var i=0;i<dep.length;i++){
		 		 						var depar = dep[i];
		 		 						var depass = "<option value='"+depar.department_id+"'>"+depar.department_name+"</option>";
		 		 						$("#selectDep").append(depass);
		 		 					}
		 		 					$("#selectDep option[value='"+staff[0].staff_departmentId+"']").attr("selected",true);
		 		 				},
		 		 				error:function(e){
		 		 					alert("发生未知错误请刷新页面");
		 		 				}

		 			   		 });
		 				},
		 				error:function(e){
		 					alert("发生未知错误请刷新页面");
		 				}

			   		 });
					$('.bianji').css('display', 'block');
		    		$('.smalls').css('display', 'block');
					
				},
				
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
       }
       function updateStaffPage(){
    	    var number = 0;
   			var obj = document.getElementsByName("items");
			for(var i = 0,l = obj.length;i < l;i++){
				if(obj[i].checked){
					number++;
				}
			} 
			if(number > 1){
				return;
			}
    	   
			var staff_id = $(".staff_id").html();
			staff_id = staff_id.substring(0,staff_id.length-1);
			$.ajax({
	 				type:"post",
	 				data:"staff_id="+staff_id,
	 				url:"<%=basePath %>staff/findById.action",
	 				success:function(data){
	 					var staff = eval("("+data+")");
	 					$("#user").val(staff[0].staff_userName);
	 					$("#pass").val(staff[0].staff_password);
	 					$("#namee").val(staff[0].staff_name);
	 					$("#phones").val(staff[0].staff_phone);
	 					$("#emails").val(staff[0].staff_email);
	 					$("#jobs").val(staff[0].staff_job);
	 					var sex = document.getElementsByName("sex");
	 					for(var se = 0;se<sex.length;se++){
	 						if(sex[se].value == staff[0].staff_sex){
	 							sex[se].checked = true;
	 						}	
	 					}
	 					var year = staff[0].staff_entryDate.year + 1900;
	 					var month = staff[0].staff_entryDate.month + 1;
 						var date = staff[0].staff_entryDate.date;
 						var staff_entryDate = year + "-" + month + "-" + date;
	 					$("#datess").val(staff_entryDate);
	 					
	 					$.ajax({
	 		 				type:"post",
	 		 				data:"id="+staff[0].staff_departmentId,
	 		 				url:"<%=basePath %>staff/findByDepId.action",
	 		 				success:function(staffId){
	 		 					var staffid = eval("("+staffId+")");
	 		 					$("#topStaffId").html("");
	 		 					var moren = "<option value=''>请选择</option>";
	 		 					$("#topStaffId").append(moren);
	 		 					for(var st = 0;st<staffid.length;st++){
	 		 						var staf = staffid[st];
	 		 						var depass = "<option value='"+staf.staff_id+"'>"+staf.staff_name+"</option>";
		 		 					$("#topStaffId").append(depass);
	 		 					}
	 		 					$("#topStaffId option[value='"+staff[0].staff_superior+"']").attr("selected",true);
	 		 					
	 		 					$("#selectDep").html("");
	 		 		    	    var baa = "<option value=''>请选择</option>";
	 		 		    	    $("#selectDep").append(baa);
	 		 					$.ajax({
	 		 		 				type:"post",
	 		 		 				url:"<%=basePath %>staff/findAllDeps.action",
	 		 		 				success:function(staff_depar){
	 		 		 					var dep = eval("("+staff_depar+")");
	 		 		 					for(var i=0;i<dep.length;i++){
	 		 		 						var depar = dep[i];
	 		 		 						var depass = "<option value='"+depar.department_id+"'>"+depar.department_name+"</option>";
	 		 		 						$("#selectDep").append(depass);
	 		 		 					}
	 		 		 					$("#selectDep option[value='"+staff[0].staff_departmentId+"']").attr("selected",true);
	 		 		 				},
	 		 		 				error:function(e){
	 		 		 					alert("发生未知错误请刷新页面");
	 		 		 				}

	 		 			   		 });
	 		 				},
	 		 				error:function(e){
	 		 					alert("发生未知错误请刷新页面");
	 		 				}

	 			   		 });
	 					
	 				},
	 				error:function(e){
	 					alert("发生未知错误请刷新页面");
	 				}

		   		 });
       }
       
       function updateStaff(){
    	   var staff_ids = $("#staff_ids").val();
    	   var staff_userName = $("#user").val();
		   var staff_password = $("#pass").val();
		   var staff_name = $("#namee").val();
		   var staff_phone = $("#phones").val();
		   var staff_email = $("#emails").val();
		   var staff_job = $("#jobs").val();
		   var staff_entryDate = $("#datess").val();
		   var staff_departmentId = $("#selectDep").val();
		   var staff_superior = $("#topStaffId").val();
		   var staff_sex = null;
		   var sex = document.getElementsByName("sex");
		   for(var i = 0;i < sex.length;i++){
			   if(sex[i].checked){
				   staff_sex = sex[i].value;
			   }
		   }
		   $.ajax({
				type:"post",
				data:{
					staff_id:staff_ids,staff_userName:staff_userName,staff_password:staff_password,
					staff_name:staff_name,staff_phone:staff_phone,staff_email:staff_email,
					staff_entryDate:staff_entryDate,staff_departmentId:staff_departmentId,
					staff_superior:staff_superior,staff_sex:staff_sex,staff_job:staff_job
					
				},
				url:"<%=basePath %>staff/update.action",
				success:function(data){
					alert(data);
					location.href="<%=basePath %>staff/selectTree.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

   		   });
		   
       }
       
       function deleteStaff(){
    	   var staff_id = $(".staff_id").html();
    	   staff_id = staff_id.substring(0,staff_id.length-1);
    	   $.ajax({
				type:"post",
				data:"staff_id="+staff_id,
				url:"<%=basePath %>staff/deleteManyId.action",
				success:function(data){
					alert(data);
					location.href="<%=basePath %>staff/selectTree.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

  		   });
		   
    	   
       }
       
       function saveStaffPage(){
    	   $("#sels").html("");
    	   var baa = "<option value=''>请选择</option>";
    	    $("#sels").append(baa);
    	   $.ajax({
 				type:"post",
 				url:"<%=basePath %>staff/findAllDeps.action",
 				success:function(staff_depar){
 					var dep = eval("("+staff_depar+")");
 					for(var i=0;i<dep.length;i++){
 						var depar = dep[i];
 						var depass = "<option value='"+depar.department_id+"'>"+depar.department_name+"</option>";
 						$("#sels").append(depass);
 					}
 				},
 				error:function(e){
 					alert("发生未知错误请刷新页面");
 				}

	   		 });
       }
       
       function selectTopStaffId(){
    	   var depId = $("#sels option:selected").val();
    	   $("#sel").html("");
    	   var baa = "<option value=''>请选择</option>";
    	    $("#sel").append(baa);
    	   $.ajax({
 				type:"post",
 				url:"<%=basePath %>staff/findByDepId.action",
 				data:"id="+depId,
 				success:function(staff_depar){
 					var dep = eval("("+staff_depar+")");
 					for(var i=0;i<dep.length;i++){
 						var depar = dep[i];
 						var depass = "<option value='"+depar.staff_id+"'>"+depar.staff_name+"</option>";
 						$("#sel").append(depass);
 					}
 				},
 				error:function(e){
 					alert("发生未知错误请刷新页面");
 				}

	   		 });
       }
       
       function saveStaff(){
		   var staff_password = $("#staffPassWord").val();
		   var staff_name = $("#staffName").val();
		   var staff_phone = $("#staffPhone").val();
		   var staff_email = $("#staffEmail").val();
		   var staff_job = $("#staffJob").val();
		   var staff_entryDate = $("#staffDate").val();
		   if(staff_entryDate == ""){
			   alert("入职时间不能为空");
			   return;
		   }
		   var staff_departmentId = $("#sels").val();
		   var staff_superior = $("#sel").val();
		   var staff_sex = null;
		   var sex = document.getElementsByName("staffSex");
		   for(var i = 0;i < sex.length;i++){
			   if(sex[i].checked){
				   staff_sex = sex[i].value;
			   }
		   }
		   $.ajax({
				type:"post",
				data:{
					staff_password:staff_password,
					staff_name:staff_name,staff_phone:staff_phone,staff_email:staff_email,
					staff_entryDate:staff_entryDate,staff_departmentId:staff_departmentId,
					staff_superior:staff_superior,staff_sex:staff_sex,staff_job:staff_job
					
				},
				url:"<%=basePath %>staff/save.action",
				success:function(data){
					alert(data);
					if(data == "账号已存在"){
						return;
					}
					location.href="<%=basePath %>staff/selectTree.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

   		   });
       }
       
       function searchBox(){
    	   
    	   var selectWhere = $("#searchBox").val();
    	   if(selectWhere == ""){
    		   return;
    	   }
    	   
    	   $.ajax({
				type:"post",
				data:"selectWhere="+selectWhere,
				url:"<%=basePath %>staff/searchBox.action",
				success:function(data){
					$.ajax({
		 				type:"post",
		 				url:"<%=basePath %>staff/findAllDeps.action",
		 				success:function(datas){
		 					var jso = eval("("+datas+")");
		 					var jsons = eval("("+data+")");
		 					$(".listStaffTr").remove();
		 					for(var i =0,l = jsons.length;i < l;i++){
		 						//alert(1);
		 						var dep_name = "";
		 						for(var j = 0,k = jso.length;j < k;j++){
		 							if(jsons[i].staff_departmentId == jso[j].department_id){
		 								dep_name = jso[j].department_name;
		 								break;
		 							}
		 						}
		 						var year = jsons[i].staff_entryDate.year + 1900;
		 						var month = jsons[i].staff_entryDate.month + 1;
		 						var date = jsons[i].staff_entryDate.date;
		 						var entryDate = year+"-"+month+"-"+date;
								var staff = "<tr class='listStaffTr'><td><input type='checkbox' name='items' value='' onclick='checkedShow()'/></td><td>"+jsons[i].staff_name+"</td><td>"+jsons[i].staff_phone+"</td><td>"+jsons[i].staff_email+"</td><td>"+jsons[i].staff_sex+"</td><td>"+jsons[i].staff_job+"</td><td>"+dep_name+"</td><td>"+entryDate+"</td></tr>";
		 						$("#updateStaff").append(staff);
		 					}
		 				},
		 				error:function(e){
		 					alert("发生未知错误请刷新页面");
		 				}

			   		 });
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
       }
       
       function updateRolePage(){
    		$.ajax({
 				type:"post",
 				url:"<%=basePath %>role/findByAll.action",
 				success:function(data){
 					var jsons = eval("("+data+")");
 					$("#roleList").html("");
 					for(var i =0,l = jsons.length;i < l;i++){
 						var json = jsons[i];
 						var str = "<p class='pac'><input type='radio' name='qianxian' value='"+json.role_id+"'>&nbsp;&nbsp;&nbsp;&nbsp;"+json.role_name+"</p>";
 						$("#roleList").append(str);
 					}
 				},
 				error:function(e){
 					alert("发生未知错误请刷新页面");
 				}

	   		 });
    	   
    	   
       }
       
       function updateRole(){
    	   var rolid = document.getElementsByName("qianxian");
    	   var roleId = 0;
    	   for(var i = 0,l = rolid.length;i < l;i++){
    		   if(rolid[i].checked){
    			roleId = rolid[i].value;   
    		   }
    	   }
    	   if(roleId == 0){
    		   alert("请选择要分配的角色");
    		   return;
    	   }
    	   var staff_id = $(".staff_id").html();
    	   staff_id = staff_id.substring(0,staff_id.length-1);
    	   
    	   
    	   $.ajax({
				type:"post",
				url:"<%=basePath %>role/updateDistributions.action",
				data:"staff_id="+staff_id+"&role_id="+roleId,
				success:function(data){
					alert(data);
					location.href="<%=basePath %>staff/selectTree.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
	       }
	       
	      function guanbin(){
	    	  $('.smalls').css('display', 'none');
	          $('.ba').css('display', 'none'); 
	      }
	      $(".pals").click(function(){
	            if($(".imgas").css("display")=="none"){
	            $(".imgas").show();
	            }else{
	            $(".imgas").hide();
	            }
	            if($(".imgbs").css("display")=="none"){
	            $(".imgbs").show();
	            }else{
	            $(".imgbs").hide();
	            }
	        });
	      function dia(id){
	    	  if($(".imgbc").css("display")=="none"){
	    		  $(".imgbc").css('display','block');
	    	  }else {
	    		  $(".imgbc").css('display','none');
	    	  }
	    	  $(".department_id").html(id);
	      }
    </script>
    
    <script type="text/javascript">
    	function selectComId(id){
    		
    		$(".companyId").html(id);
    	}
    	
    	function saveDepDow(){
    		var fenzu = $("#fenzus").val();
    		if(fenzu == ""){
    			alert("请输入小组名称");
    			return;
    		}
    		var depId = $(".department_id").html();
    		var copId = $(".companyId").html();
    		if(depId == "" || copId == ""){
    			alert("新增失败");
    			location.href="../staff/selectTree.action";
    		}
    		$.ajax({
				type:"post",
				url:"<%=basePath %>staff/saveDepartment.action",
				data:"department_name="+fenzu+"&department_departmentId="+depId+"&department_companyId="+copId,
				success:function(data){
					alert(data);
					location.href="<%=basePath %>staff/selectTree.action";
				},
				error:function(e){
					alert("发生未知错误请刷新页面");
				}

	   		 });
    		
    		
    	}
    	
    	function UpladFile() {
  		   var fileObj = document.getElementById("filea").files[0]; // js 获取文件对象
  		   var FileController = "../staff/staffImput.action";     // 接收上传文件的后台地址 
  		   // FormData 对象
  		   var form = new FormData();
  		   form.append("author", "hooyes");      // 可以增加表单数据
  		   form.append("file", fileObj);       // 文件对象
  		   // XMLHttpRequest 对象
  		   var xhr = new XMLHttpRequest();
  		   xhr.open("post", FileController, true);
  		   xhr.onload = function (date) {
  		    
  		   };
  		   xhr.onreadystatechange = function(){
  			  if(xhr.readyState == 4){//4：读取完成
 	             if(xhr.status==200){
 	                  alert(xhr.responseText);
 	                  location.href= "<%=basePath%>/staff/selectTree.action";
 	              }
 	              
 	          }
  		   }
  		  // xhr.upload.addEventListener("progress", progressFunction, false);
  		   xhr.send(form);
  		  }
  	 	  function progressFunction(evt) {
  			   var progressBar = document.getElementByIdx_x_x("progressBar");
  			   var percentageDiv = document.getElementByIdx_x_x("percentage");
  		  }
  	 	function ind(){
  	    	window.location.href= "../notice/findByAll.action";
  	    }
    </script>
</html>